package org.renhj.metric;

public class Metric implements Comparable<Metric>{

    private String address;
    private Long start;
    private Long end;
    private Long cost;


    public Metric(String address, Long start,Long end, Long cost) {
        this.address = address;
        this.start = start;
        this.end = end;
        this.cost = cost;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getStart() {
        return start;
    }

    public void setStart(Long start) {
        this.start = start;
    }

    public Long getCost() {
        return cost;
    }

    public void setCost(Long cost) {
        this.cost = cost;
    }

    public Long getEnd() {
        return end;
    }

    public void setEnd(Long end) {
        this.end = end;
    }

    @Override
    public int compareTo(Metric o) {
        return this.cost.compareTo(o.getCost());
    }


    @Override
    public String toString() {
        return "Metric{" +
                "address='" + address + '\'' +
                ", start=" + start +
                ", end=" + end +
                ", cost=" + cost +
                '}';
    }

    public byte[] toBytes() {
        return this.toString().getBytes();
    }

    public void calcCost() {
        this.cost = this.end - this.start;
    }
}
